define(['app'], function(app) {
    'use strict';

    //实例化方法
    var factory = function(Http) {
        function get_data_activitySetting(result) {
            if(HTTP_ISLOGIC) {
                result = '{"success": true,"msg": "","result": { "act_id": "001", "name": "团购","start_time": "2017/01/01 09:00:00","end_time": "2017/01/31 09:00:00",' +
                    '"create_group": true,"has_packets": true,"image": [{"id": "001","image": "img/upload/pro-img01.jpg"},{"id": "002","image": "img/upload/pro-img01.jpg"}],"brand_id": "001","brand_name": "博朗","cat_type": [{"id": "001","name": "工具类-扳手类-家用扳手"},{"id": "002" ,"name": "工具类-扳手类-家用扳手"}]' +
                    '},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            } else {
                return result;
            }
        }

        function get_data_auctionProduct(result) {
            if(HTTP_ISLOGIC) {
                result = '{"success": true,"msg": "","result": { "store": [' +
                    '{"store_id": "001","store_name": "世达","change_price": true,"margin_price": 10000,"start_price": 100,"add_price": 50,' +
                    '"floor_price": 100,"count": 10,"region": [{"region_id": "001","region_name": "江苏"},{"region_id": "002","region_name": "浙江"}]},' +
                    '{"store_id": "002","store_name": "博士","change_price": false,"margin_price": 10000,"start_price": 100,"add_price": 50,' +
                    '"floor_price": 100,"count": 10,' + '"region": [{"region_id": "001", "region_name": "江苏"},{"region_id": "002","region_name": "浙江"}]}' +
                    '],' +
                    '"goods_id": "001","goods_name": "一字螺丝刀","image": "img/upload/pro-img01.jpg"' +
                    '},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            } else {
                return result;
            }

        }
        //拍卖对象
            function get_data_auctionDealer(result) {
                if(HTTP_ISLOGIC) {
                    result = '{"success":true,"msg":"","result":{"change_price":true,"region":[{"region_id":"001","region_name":"江苏","is_all":true,"store":[{"store_id":"001","store_name":"世达"},{"store_id":"002","store_name":"博士"}]},{"region_id":"002","region_name":"浙江","is_all":true,"store":[{"store_id":"001","store_name":"世达2"},{"store_id":"002","store_name":"博士2"}]}],"goods_id":"001","goods_name":"一字螺丝刀","image":"img/upload/pro-img01.jpg","margin_price":10000,"start_price":100,"add_price":50,"floor_price":100,"count":10},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
                    return JSON.parse(result);
                } else {
                    return result;
                }
            }

        //返回信息
        return {
            activitySetting: function(act_id, callback) {
                Http.post({
                        method: 'marketing.seckill.detail',
                        act_id: act_id
                    },
                    function(result) {
                        //请求成功
                        if(callback)
                            callback(get_data_activitySetting(result).result);
                    },
                    function(e) {
                        //请求异常
                    },
                    function() {
                        //请求完成，一般不做什么事情
                    });
            },
            acutionProduct: function(act_id, callback) {
                Http.post({
                        method: 'marketing.auction.agenter',
                        act_id: act_id
                    },
                    function(result) {
                        //请求成功
                        if(callback)
                            callback(get_data_auctionProduct(result).result);
                    },
                    function(e) {
                        //请求异常
                    },
                    function() {
                        //请求完成，一般不做什么事情
                    });
            },
            auction_edit: function(act_id, region, goods, callback) {
                Http.post({
                        method: 'marketing.auction.agenterjion',
                        updateParams: {
                            act_id: act_id,
                            region: region,
                            goods: goods,
                        },
                    },
                    function(result) {

                    },
                    function(e) {
                        //请求异常
                    },
                    function() {
                        //请求完成，一般不做什么事情
                    });

            },
            auction_dealer: function(act_id, callback) {
                Http.post({
                        method: 'marketing.auction.dealer',
                        act_id: act_id,
                    },
                    function(result) {
                        //请求成功
                        if(callback)
                            callback(get_data_auctionDealer(result).result);
                    },
                    function(e) {
                        //请求异常
                    },
                    function() {
                        //请求完成，一般不做什么事情
                    });
            },

        };
    }

    factory.$inject = ['Http'];
    return app.registerService("Auction_agent", factory);
});